﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Acme.BookStore2.Migrations
{
    public partial class inspectmaintenanceattach : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AppVehicleInspectionRecord_AttachFiles",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    FileName = table.Column<string>(nullable: true),
                    BlobContainerName = table.Column<string>(nullable: true),
                    BlobName = table.Column<string>(nullable: true),
                    OwnerId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppVehicleInspectionRecord_AttachFiles", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AppVehicleInspectionRecord_AttachFiles_AppVehicleInspectionR~",
                        column: x => x.OwnerId,
                        principalTable: "AppVehicleInspectionRecord",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "AppVehicleMaintenanceRecord_AttachFiles",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    FileName = table.Column<string>(nullable: true),
                    BlobContainerName = table.Column<string>(nullable: true),
                    BlobName = table.Column<string>(nullable: true),
                    OwnerId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppVehicleMaintenanceRecord_AttachFiles", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AppVehicleMaintenanceRecord_AttachFiles_AppVehicleMaintenanc~",
                        column: x => x.OwnerId,
                        principalTable: "AppVehicleMaintenanceRecord",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AppVehicleInspectionRecord_AttachFiles_OwnerId",
                table: "AppVehicleInspectionRecord_AttachFiles",
                column: "OwnerId");

            migrationBuilder.CreateIndex(
                name: "IX_AppVehicleMaintenanceRecord_AttachFiles_OwnerId",
                table: "AppVehicleMaintenanceRecord_AttachFiles",
                column: "OwnerId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AppVehicleInspectionRecord_AttachFiles");

            migrationBuilder.DropTable(
                name: "AppVehicleMaintenanceRecord_AttachFiles");
        }
    }
}
